<template>
  <!-- 组件必须只能有一个根标签 -->
  <div>
    <!-- 标签要么原样写,要么转小写中间以 - 分隔 -->
    <TypeNav></TypeNav>
    <list-container></list-container>
    <today-recomend></today-recomend>
    <Rank></Rank>
    <Like></Like>
    <Floor v-for="floor in floors" :key="floor.id" :floor="floor" />
    <Brand></Brand>
  </div>
</template>

<script>
import { mapState } from 'vuex'
import ListContainer from './ListContainer'
import TodayRecomend from './TodayRecomend'
import Rank from './Rank/Rank.vue'
import Like from './Like/Like.vue';
import Floor from './Floor/Floor.vue'
import Brand from './Brand/Brand.vue'

export default {
  name: 'Home',
  // 注册局部组件
  components: {
    ListContainer,
    TodayRecomend,
    Rank,
    Like,
    Floor,
    Brand
  },
  mounted () {
    this.$store.dispatch('getRecommends')
    this.$store.dispatch('getFloors')
  },
  computed: {
    ...mapState({
      floors: state => state.home.floors
    })
  }
}
</script>
